package com.ynkbny.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ynkbny.domain.SystemLog;
import com.ynkbny.mapper.SystemLogMapper;
import com.ynkbny.service.SystemLogService;
import com.ynkbny.util.SearchUtil;
import com.ynkbny.util.UserRoleUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author YY
* @description 针对表【system_log(系统日志表 系统日志表)】的数据库操作Service实现
* @createDate 2023-08-17 10:20:41
*/
@Slf4j
@Service
public class SystemLogServiceImpl extends ServiceImpl<SystemLogMapper, SystemLog>
    implements SystemLogService{

    @Resource
    private SystemLogMapper systemLogMapper;

    @Resource
    private UserRoleUtil<SystemLog> userRoleUtil;

    /**
     * 分页查询
     *
     * @Author YY
     * @param pageNum 页码
     * @param pageSize 单页条数
     * @param conditionJson 查询条件
     * @return 分页数据
     */
    @Override
    public Page<SystemLog> selectByPage(Long pageNum, Long pageSize, String conditionJson) {
        Page<SystemLog> pageParam = new Page<>(pageNum,pageSize);
        QueryWrapper<SystemLog> queryWrapper = SearchUtil.parseWhereSql(null,null,conditionJson);
        Page<SystemLog> pageList = userRoleUtil.getPageList(pageParam, queryWrapper, this.baseMapper);
        return pageList;
    }

    @Override
    public Long reportCount(String date1,String date2,List<String> enterpriseCodes) {
        return systemLogMapper.reportCount(date1,date2,enterpriseCodes);
    }

    @Override
    public Long totalReportCount(String date1,String date2,List<String> enterpriseCodes) {
        return systemLogMapper.totalReportCount(date1,date2,enterpriseCodes);
    }
}




